<template>
  <div>
    <search-table :url="url"
                  ref="searchtable"
                  :hideSelect="true"
                  :columns="columns"
                  :form="form"
                  style="margin-top:20px;"
                  :goodsName="goodsName"
                  :goodsPicture="goodsPicture"
                  :default-params="defaultParams">

      <template slot="searchForm">
        <a-form layout="inline"
                :form="form">
          <a-form-item label="编码搜索">
            <a-input v-decorator="['code']"
                     placeholder="编码搜索">
            </a-input>
          </a-form-item>

          <a-form-item label="领取状态">
            <a-select v-decorator="['isReceive']"
                      :options="lingquzhuangtaiList"
                      style="width: 180px"
                      placeholder="领取状态">
            </a-select>
          </a-form-item>

          <a-form-item label="核销状态">
            <a-select v-decorator="['writeOff']"
                      :options="hexiaozhuangtaiList"
                      allowClear
                      style="width: 180px"
                      placeholder="核销状态">
            </a-select>
          </a-form-item>
          <a-form-item label="用户昵称">
            <a-input v-decorator="['keyword']"
                     placeholder="用户昵称">
            </a-input>
          </a-form-item>

          <a-form-item label="导购ID">
            <a-input v-decorator="['shoppersId']"
                     placeholder="导购ID">
            </a-input>
          </a-form-item>

          <a-form-item label="导购昵称">
            <a-input v-decorator="['shoppersName']"
                     placeholder="导购昵称">
            </a-input>
          </a-form-item>
          <a-form-item label="导购电话">
            <a-input v-decorator="['shoppersPhone']"
                     placeholder="导购电话">
            </a-input>
          </a-form-item>
          <a-form-item label="所属门店">
            <a-input v-decorator="['shopName']"
                     placeholder="所属门店">
            </a-input>
          </a-form-item>
          <a-form-item label="门店ID">
            <a-input v-decorator="['shopId']"
                     placeholder="门店ID">
            </a-input>
          </a-form-item>
          <a-form-item label="领取时间">
            <fast-range-picker
                    v-decorator="[
                'receiveStartDate-receiveEndDate',
              ]"
            >
            </fast-range-picker>
          </a-form-item>

          <a-form-item label="核销时间">
            <fast-range-picker
                    v-decorator="[
                'writeOffStartDate-writeOffEndDate',
              ]"
            >
            </fast-range-picker>
          </a-form-item>


          <br>
          <a-form-item>
            <a-button type="primary" class="searchBtn" icon="search" @click="searchData">搜索</a-button>
          </a-form-item>

          <a-form-item>
            <a-button type="primary" class="searchBtn" icon="reload" @click="resertSearchData">重置</a-button>
          </a-form-item>

          <a-form-item>
                        <a-button @click="exportss" icon="export" type="primary">导出</a-button>
          </a-form-item>

          <a-form-item label="">
            <a-button @click="back" type="plain" icon="backword"> 返回</a-button>
          </a-form-item>
        </a-form>
      </template>
    </search-table>
  </div>
</template>

<script>
  import SearchTable from "../components/SearchTable";
  export default {
    name: "goodsCode",
    created() {
      this.defaultParams.selfGoodsId = this.$route.query.id
      this.goodsName = this.$route.query.goodsName
      this.goodsPicture = this.$route.query.goodsPicture
    },
    components:{
      SearchTable
    },
    data(){
      return {
        goodsName:'',
        goodsPicture:'',
        defaultParams:{
          selfGoodsId:''
        },
        lingquzhuangtaiList:[{label:'全部',value:''},{label:'已领取',value:'1'},{label:"未领取",value: "0"}],
        hexiaozhuangtaiList:[{label:'全部',value:''},{label:'已核销',value:'1'},{label:"未核销",value: "0"}],

        url: 'goldenhome/gh/lottery_/admin/self/buildgoods/code/page',
        form: this.$form.createForm(this, {name: 'table_search'}),
        columns: [
          {
            title: '商品名称',
            dataIndex: 'goodsName',
            key: 'goodsName',
            // align: 'center',
            customRender:(text,row)=>{
              return <div class="product_td"><table-img src={row.goodsPicture}/><div class="product_name">{text}</div></div>
            }
          },
          {
            title: '编码',
            dataIndex: 'code',
            key: 'code'
          },
          {
            title: '领取状态',
            dataIndex: 'isReceive',
            key: 'isReceive',
            customRender:(text,row)=>{
              if (!!row.receiveDate){
                return "已领取"
              } else {
                return "未领取"
              }
            }
          },
          {
            title: '领取用户昵称',
            dataIndex: 'customerName',
            key: 'customerName',
            align: 'center'
          },

          {
            title: '领取时间',
            dataIndex: 'receiveDate',
            key: 'receiveDate',
          },
          {
            title: '核销状态',
            dataIndex: 'writeOff',
            key: 'writeOff',
            customRender:(text,row)=>{
              if (!!row.writeOffDate){
                return "已核销"
              } else {
                return "未核销"
              }
            }
          },
          {
            title: '核销时间',
            dataIndex: 'writeOffDate',
            key: 'writeOffDate'
          },
          {
            title: '导购昵称',
            dataIndex: 'shoppersName',
            key: 'shoppersName',
          },
          {
            title: '导购电话',
            dataIndex: 'shoppersPhone',
            key: 'shoppersPhone',
          },
          {
            title: '导购ID',
            dataIndex: 'shoppersId',
            key: 'shoppersId',
          },
          {
            title: '所属门店',
            dataIndex: 'shopName',
            key: 'shopName',
          },
          {
            title: '门店ID',
            dataIndex: 'shopId',
            key: 'shopId',
          },
        ],
      }
    },
    methods:{
      searchData(){
        this.$refs.searchtable.handleSearch()
      },

      resertSearchData(){
        console.log("重置搜索条件")
        this.form.resetFields()
        this.searchData()
        /*   this.form.setFieldsValue({
             cardName:'',
             status: "1"
           })*/
      },
      back(){
        this.$router.push({
          name: 'MarketingSelfCreateGood',
        })
      },
      exportss(){
        this.$export('goldenhome/gh/lottery_/admin/self/buildgoods/code/export',{...this.$refs.searchtable.searchParams} || {})
      }
    }
  }
</script>

<style scoped>

</style>